<%@ page language="java" pageEncoding="UTF-8" isErrorPage="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="base" value="${pageContext.request.contextPath}"/>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>
        <c:choose>
            <c:when test="${loggin==true}">欢迎您回来</c:when>
            <c:otherwise>请先登录</c:otherwise>
        </c:choose>
    </title>
</head>
<body>
<div align="center" style="margin: 10px;">
    <fieldset>
        <legend>
            当前有效的 Cookie
        </legend>
        <script>
            document.write(document.cookie);
        </script>
    </fieldset>
    <fieldset>
        <legend>
            <c:choose>
                <c:when test="${loggin ==true}">
                    欢迎您回来
                </c:when>
                <c:otherwise>
                    请先登录
                </c:otherwise>
            </c:choose>
        </legend>
        <c:choose>
            <c:when test="${loggin==true}">
                欢迎您, ${cookie.account.value }   
                <a href="${base}/loginOutCookieServlet?action=logout">注 销</a>
            </c:when>
            <c:otherwise>
                <form action="${base}/loginCookieServlet?action=login" method="post">
                    <table>
                        <tr>
                            <td>
                                帐号：
                            </td>
                            <td>
                                <input type="text" name="account" style="width: 200px;">
                            </td>
                        </tr>
                        <tr>
                            <td>
                                密码：
                            </td>
                            <td>
                                <input type="password" name="password" style="width: 200px;">
                            </td>
                        </tr>
                        <tr>
                            <td>
                                有效期：
                            </td>
                            <td>
                                <input type="radio" name="timeout" value="-1" checked>
                                关闭浏览器即失效
                                <br/>
                                <input type="radio" name="timeout"
                                       value="<%=30 * 24 * 60 * 60%>">
                                30天内有效
                                <br/>
                                <input type="radio" name="timeout"
                                       value="<%=Integer.MAX_VALUE%>">
                                永久有效
                                <br/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td>
                                <input type="submit" value=" 登  录 " class="button">
                            </td>
                        </tr>
                    </table>
                </form>
            </c:otherwise>
        </c:choose>
    </fieldset>
</div>
</body>
</html>
